<template>
  <div>
    <!-- :title="title" -->
    <k-form-design @save="handleSave"  ref='kfd'/>
  </div>
</template>
<script>
import {addFormDesign,editFormDesign } from '@/api/api'
import { setFormDesignConfig,KFormDesign } from 'k-form-design'
import {Input} from "ant-design-vue";

export default {
  data() {
    return {
      title: '表单设计',
      formDesign: this.$route.query.data,
      jsonData: this.$route.query.data.data
    }
  },
  created() {

  },
  mounted() {
    if (this.jsonData) {
      this.importData(this.jsonData)
    }
  },
  methods: {
    handleSave(values) {
      console.log(values);
      this.formDesign.data = values
      editFormDesign(this.formDesign).then((res)=>{
        if (res.code == 200)
            this.$message.success(res.message)
        else
            this.$message.error(res.message)
      })
    },
    importData (jsonData) {
      console.log(jsonData);
      this.$refs.kfd.handleSetData(JSON.parse(jsonData))
    }
  }
};
</script>